package com.linjiu.myapp;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.linjiu.xpermissionclent.XPermissionClient;

import java.util.List;

public class MainActivity extends AppCompatActivity {
    private final static String TAG="MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button test1=(Button) findViewById(R.id.tv_test);
        test1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                new XPermissionClient(MainActivity.this)
                        .getAppPermission(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}, new XPermissionClient.PermissionBack() {
                            @Override
                            public void back(XPermissionClient.PermissionStatus permissionStatus, List<String>... permissions) {

                            }

                            @Override
                            public void pre() {
                                Log.e(TAG,"pre");
                            }
                        });




            }
        });

        Button test2=(Button) findViewById(R.id.tv_test2);
        test2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                new XPermissionClient(MainActivity.this)
                        .setStrTopTipsTitle("存储权限提示")
                        .setStrTopTipsContent("因为XXX需要申请存储权限")
                        .setShowPermissionDialogTopTips(true)
                        .getAppPermission(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}, new XPermissionClient.PermissionBack() {
                            @Override
                            public void back(XPermissionClient.PermissionStatus permissionStatus, List<String>... permissions) {

                            }

                            @Override
                            public void pre() {

                            }
                        });

            }
        });


    }







}